/* SPDX-License-Identifier: GPL-2.0 */

#ifndef __AXVU_H__
#define __AXVU_H__

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

#include "ax.h"

#ifdef VX_CMDQ
#define IVX_BASE_ADDR         0x00000000 /* 0x01780000 */
#define IVX_TOP_VER          (IVX_BASE_ADDR + 0x00)
#define IVX_TOP_FTR          (IVX_BASE_ADDR + 0x04)

#define IVX_ADPLL_CTRL       (IVX_BASE_ADDR + 0x08)
#define IVX_ADPLL_MEASURE    (IVX_BASE_ADDR + 0x0c)
#define IVX_ADPLL_FAC        (IVX_BASE_ADDR + 0x10)
#define IVX_ADPLL_TUNE0      (IVX_BASE_ADDR + 0x14)
#define IVX_ADPLL_TUNE1      (IVX_BASE_ADDR + 0x18)
#define IVX_ADPLL_STAT       (IVX_BASE_ADDR + 0x1c)
#define IVX_RESET            (IVX_BASE_ADDR + 0x20)

#define IVX_CORE_RST         (IVX_BASE_ADDR + 0x100)
#define IVX_ADDR_OFT         (IVX_BASE_ADDR + 0x104)
#define IVX_OCM              (IVX_BASE_ADDR + 0x108)
#define IVX_TASK_STATUS      (IVX_BASE_ADDR + 0x10c)

#define IVX_CTL              (IVX_BASE_ADDR + 0x110)
#define IVX_CMD_NUM0         (IVX_BASE_ADDR + 0x114)
#define IVX_CMD_NUM1         (IVX_BASE_ADDR + 0x118)
#define IVX_FIRST_CMD_LEN    (IVX_BASE_ADDR + 0x11c)

#define IVX_INT_EN           (IVX_BASE_ADDR + 0x120)
#define IVX_INT_PD           (IVX_BASE_ADDR + 0x124)
#define IVX_INT_CLR          (IVX_BASE_ADDR + 0x128)
#define IVX_STATUS           (IVX_BASE_ADDR + 0x12c)

#define IVX_CMD_ADDR0        (IVX_BASE_ADDR + 0x130)
#define IVX_CMD_ADDR1        (IVX_BASE_ADDR + 0x134)
#define IVX_CMD_ADDR2        (IVX_BASE_ADDR + 0x138)
#define IVX_CMD_ADDR3        (IVX_BASE_ADDR + 0x13c)

#define IVX_CMD_ADDR4        (IVX_BASE_ADDR + 0x140)
#define IVX_CMD_ADDR5        (IVX_BASE_ADDR + 0x144)
#define IVX_CMD_ADDR6        (IVX_BASE_ADDR + 0x148)
#define IVX_CMD_ADDR7        (IVX_BASE_ADDR + 0x14c)

#define IVX_PERF              (IVX_BASE_ADDR + 0x150)
#define IVX_BW_R              (IVX_BASE_ADDR + 0x154)
#define IVX_BW_W              (IVX_BASE_ADDR + 0x158)
#define IVX_BW_DDR_R          (IVX_BASE_ADDR + 0x15c)
#define IVX_BW_DDR_W          (IVX_BASE_ADDR + 0x160)
#else
/* TOP base registers */
#define IVX_BASE_ADDR         0x00000000 /* 0x01780000 */
#define IVX_TOP_VER          (IVX_BASE_ADDR + 0x00)
#define IVX_TOP_FTR          (IVX_BASE_ADDR + 0x04)

#define IVX_ADPLL_CTRL       (IVX_BASE_ADDR + 0x08)
#define IVX_ADPLL_FAC        (IVX_BASE_ADDR + 0x10)
#define IVX_ADPLL_TUNE0      (IVX_BASE_ADDR + 0x14)
#define IVX_ADPLL_TUNE1      (IVX_BASE_ADDR + 0x18)
#define IVX_ADPLL_STAT       (IVX_BASE_ADDR + 0x1c)

#define IVX_CTL              (IVX_BASE_ADDR + 0x110)
#define IVX_RST              (IVX_BASE_ADDR + 0x100)

#define IVX_INT_EN           (IVX_BASE_ADDR + 0x120)
#define IVX_INT_PD           (IVX_BASE_ADDR + 0x124)
#define IVX_INT_CLR          (IVX_BASE_ADDR + 0x128)

#define IVX_PERF              (IVX_BASE_ADDR + 0x12c)
#define IVX_BW_R              (IVX_BASE_ADDR + 0x130)
#define IVX_BW_W              (IVX_BASE_ADDR + 0x134)
#define IVX_BW_DDR_R          (IVX_BASE_ADDR + 0x138)
#define IVX_BW_DDR_W          (IVX_BASE_ADDR + 0x13c)

#define IVX_CFG0                (IVX_BASE_ADDR + 0x200)
#define IVX_MERGE_CFG0          (IVX_BASE_ADDR + 0x2D0)


#define IVX_MBGS_CFG0        (IVX_BASE_ADDR + 0x200)
#define IVX_MBGS_CFG1        (IVX_BASE_ADDR + 0x204)
#define IVX_MBGS_CFG2        (IVX_BASE_ADDR + 0x208)
#define IVX_MBGS_CFG3        (IVX_BASE_ADDR + 0x20C)
#define IVX_MBGS_CFG4        (IVX_BASE_ADDR + 0x210)
#define IVX_MBGS_CFG5        (IVX_BASE_ADDR + 0x214)
#define IVX_MBGS_CFG6        (IVX_BASE_ADDR + 0x218)
#define IVX_MBGS_CFG7        (IVX_BASE_ADDR + 0x21C)


typedef enum eiAXVU_FMT_E {
	RGB = 0x00,
	RGB_WHC = 0x01,
	YUV420 = 0x02,
	YVU420 = 0x04,
	GRAY = 0x06,
	GRAY_WHC = 0x07,
	ARGB = 0x08,
	ARGB_WHC = 0x09,
	STEREO_ARGB = 0x18,
	STEREO_ARGB_WHC = 0x19,

	WHC_MASK = 0x1,
	TYPE_MASK = 0xE,
	STEREO_MASK = 0x10,
} AXVU_FMT_E;


#endif


typedef struct eiAXVU_INFO_S {
	AXVU_STAT_INFO_S stat_info;
#ifdef VX_CMDQ
	AXVU_CTL_S clt_info;
#else
	AXVU_RSZ_CFG_S rsz_cfg;
	AXVU_MBG_CFG_S mbg_cfg;
#endif
	unsigned int vu_count;
	unsigned int vu_status;
} AXVU_INFO_S;

typedef enum eiAXVU_STAT_CODE_E {
	AXVU_IDLE,
	AXVU_BUSY,
	AXVU_PAUSED,
	AXVU_STOPPED,
	AXVU_ERR,
} AXVU_STAT_CODE_E;

typedef enum eiAXVU_ERR_CODE_E {
	AXVU_OK = 0,
	AXVU_WAIT  = -1,
	AXVU_ERR_UNKNOWN = -2,
	AXVU_ERR_BUSY = -100,
	AXVU_ERR_CFG = -101,
	AXVU_ERR_TIMEOUT = -203
} AXVU_ERR_CODE_E;

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

#endif

